- breadcrumb_title _('Runners')
- @no_container = true

%div{ class: container_class }
  .bs-callout
    %p
      = (_"A 'Runner' is a process which runs a job. You can setup as many Runners as you need.")
      %br
      = _('Runners can be placed on separate users, servers, even on your local machine.')
      %br

    %div
      %span= _('Each Runner can be in one of the following states:')
      %ul
        %li
          %span.badge.badge-success shared
          \-
          = _('Runner runs jobs from all unassigned projects')
        %li
          %span.badge.badge-success group
          \-
          = _('Runner runs jobs from all unassigned projects in its group')
        %li
          %span.badge.badge-info specific
          \-
          = _('Runner runs jobs from assigned projects')
        %li
          %span.badge.badge-warning locked
          \-
          = _('Runner cannot be assigned to other projects')
        %li
          %span.badge.badge-danger paused
          \-
          = _('Runner will not receive any new jobs')

  .bs-callout.clearfix
    .float-left
      %p
        = _('You can reset runners registration token by pressing a button below.')
      .prepend-top-10
        = button_to _('Reset runners registration token'), reset_runners_token_admin_application_settings_path,
          method: :put, class: 'btn btn-default',
          data: { confirm: _('Are you sure you want to reset registration token?') }

  = render partial: 'ci/runner/how_to_setup_shared_runner',
           locals: { registration_token: Gitlab::CurrentSettings.runners_registration_token }

  .bs-callout
    %p
      = _('Runners currently online: %{active_runners_count}') % { active_runners_count: @active_runners_count }

  .row-content-block.second-block
    = form_tag admin_runners_path, id: 'runners-search', method: :get, class: 'filter-form js-filter-form' do
      .filtered-search-wrapper
        .filtered-search-box
          = dropdown_tag(custom_icon('icon_history'),
            options: { wrapper_class: 'filtered-search-history-dropdown-wrapper',
            toggle_class: 'filtered-search-history-dropdown-toggle-button',
            dropdown_class: 'filtered-search-history-dropdown',
            content_class: 'filtered-search-history-dropdown-content',
            title: _('Recent searches') }) do
            .js-filtered-search-history-dropdown{ data: { full_path: admin_runners_path } }
          .filtered-search-box-input-container.droplab-dropdown
            .scroll-container
              %ul.tokens-container.list-unstyled
                %li.input-token
                  %input.form-control.filtered-search{ { id: 'filtered-search-runners', placeholder: _('Search or filter results...') } }
            #js-dropdown-hint.filtered-search-input-dropdown-menu.dropdown-menu.hint-dropdown
              %ul{ data: { dropdown: true } }
                %li.filter-dropdown-item{ data: { action: 'submit' } }
                  = button_tag class: %w[btn btn-link] do
                    = sprite_icon('search')
                    %span
                      = _('Press Enter or click to search')
              %ul.filter-dropdown{ data: { dynamic: true, dropdown: true } }
                %li.filter-dropdown-item
                  = button_tag class: %w[btn btn-link] do
                    -# Encapsulate static class name `{{icon}}` inside #{} to bypass
                    -# haml lint's ClassAttributeWithStaticValue
                    %svg
                      %use{ 'xlink:href': "#{'{{icon}}'}" }
                    %span.js-filter-hint
                      {{hint}}
                    %span.js-filter-tag.dropdown-light-content
                      {{tag}}
            #js-dropdown-admin-runner-status.filtered-search-input-dropdown-menu.dropdown-menu
              %ul{ data: { dropdown: true } }
                - Ci::Runner::AVAILABLE_STATUSES.each do |status|
                  %li.filter-dropdown-item{ data: { value: status } }
                    = button_tag class: %w[btn btn-link] do
                      = status.titleize
          = button_tag class: %w[clear-search hidden] do
            = icon('times')
        .filter-dropdown-container
          = render 'sort_dropdown'

  - if @runners.any?
    .runners-content.content-list
      .table-holder
        .gl-responsive-table-row.table-row-header{ role: 'row' }
          - [_('Type'), _('Runner token'), _('Description'), _('Version'), _('IP Address'), _('Projects'), _('Jobs'), _('Tags'), _('Last contact')].each do |label|
            .table-section.section-10{ role: 'rowheader' }= label

        - @runners.each do |runner|
          = render 'admin/runners/runner', runner: runner
      = paginate @runners, theme: 'gitlab'
  - else
    .nothing-here-block= _('No runners found')
